# try:
#     open('./data.txt', 'r', encoding='utf-8') as file:
#     content = file.read()
#     print(1 / 0)
#     print(content)
# except FileNotFoundError:
#     print('文件未找到')
# except PermissionError:
#     print('文件没有权限')
# except UnicodeDecodeError:
#     print('编码错误')
# except ZeroDivisionError:
#     print('分母为0错误')
# except IOError as e:
#     print(f'发生其他错误{e}')
# finally:
#     file.close()
#
#
# print('之后执行的代码')
import os.path

# import re
# file = None
# words = dict()
# try:
#     file = open('./pride-and-prejudice.txt', 'r', encoding='UTF-8')
#     for line in file:
#         words_in_line = re.findall(r'\b[a-zA-Z]+\b', line)
#         words_in_line = [word.lower() for word in words_in_line]
#         for word in words_in_line:
#             if word not in words:
#                 words[word] = 0
#             words[word] += 1
#     print(words)
# except Exception as e:
#     print(e)

from tqdm import tqdm
import time
import os
def copy_file(source_path, destination_path):
    chunk_size = 1024 * 1024
    file_size = os.path.getsize(source_path)
    copied_size = 0
    with open(source_path, 'rb') as source_file, open(destination_path, 'wb') as destination_file:
        with tqdm(total=file_size, unit='B', unit_scale=True, desc='当前进度') as progess_bar:
            while True:
                chunk = source_file.read(chunk_size)
                if not chunk:
                    break
                destination_file.write(chunk)
                copied_size += len(chunk)
                progess_bar.update(len(chunk))
            print('复制完成')


if __name__ == "__main__":
    s = "E:\\Linux\\镜像CentOS-7-x86_64-Minimal-2009.iso"
    d = "E:\\Linux\\镜像CentOS-7-x86_64-Minimal-2009-copy.iso"
    copy_file(s, d)